#include "GameView.h"
#include "ViewContent.h"

using namespace Views;

GameView::GameView(const ViewContent &content, TCODConsole *parent)
	: IView(content.getName()), parent(parent)
{
	init(content);
}

GameView::~GameView()
{
}

void GameView::init(const ViewContent &content)
{
	assert(content.getType() == VIEW_GAME);

	viewport.x = content.getWidth();
	viewport.y = content.getHeight();
	position.x = content.getX();
	position.y = content.getY();
	alpha.x = content.getForegroundAlpha();
	alpha.y = content.getBackgroundAlpha();
	alignment = content.getAlignment();

	console = std::unique_ptr<TCODConsole>(new TCODConsole(viewport.x, viewport.y));
	console->setAlignment((TCOD_alignment_t)alignment);
	console->setDefaultBackground(TCODColor::black);
	console->setDefaultForeground(TCODColor::white);
	console->clear();
}

void GameView::update(float dt)
{
}

void GameView::render()
{
	TCODConsole::blit(console.get(), 0, 0, viewport.x, viewport.y, parent, position.x, position.y, alpha.x, alpha.y);
}

bool GameView::inputKeyDown(TCOD_key_t &key, TCOD_mouse_t &mouse)
{
	return false;
}

bool GameView::inputKeyUp(TCOD_key_t &key, TCOD_mouse_t &mouse)
{
	return false;
}

bool GameView::motion(TCOD_key_t &key, TCOD_mouse_t &mouse)
{
	return false;
}

bool GameView::mousePressed(TCOD_key_t &key, TCOD_mouse_t &mouse)
{
	return false;
}

bool GameView::mouseReleased(TCOD_key_t &key, TCOD_mouse_t &mouse)
{
	return false;
}
